package fr;

import java.io.IOException;
import java.net.InetAddress;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;







public class FiltreIp implements Filter {



	public FiltreIp() {

		System.out.println("in ifilter");

	}





	@Override
	public void doFilter(ServletRequest request, ServletResponse resp,
			FilterChain chain) throws IOException, ServletException {

		String ipAddress = request.getRemoteAddr();
		InetAddress Ip =InetAddress.getLocalHost();
		// Get IP
		
		

			ipAddress= request.getRemoteAddr();
		     Ip =InetAddress.getLocalHost();
			
			request.setAttribute("monIp", ipAddress);
			request.setAttribute("IP", Ip);


			
			
		chain.doFilter(request, resp);

	}
	
	 


	@Override
	public void destroy() {

		System.out.println("i' dead :/");

	}





	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}

}
